
public class BankDatabase {
	
	private Account[] accounts;
	
	public BankDatabase() {
		accounts = new Account[2];
		accounts[0] = new Account(11123, 1234, 1000.0, 1200.0);
		accounts[1] = new Account(22456, 3214, 500.0, 9000.0);
	}
	
	// wybranie numeru kont
	
	private Account getAccount(int accountNumber) {
		for(Account a : this.accounts) {
			if(a.getAccountNumber() == accountNumber) return a;
			
		}
		
		return null;
	}

    public boolean authenticateUser(int accountNumber, int pin) {
	
    	Account account = this.getAccount(accountNumber);
    	if(account != null) {
    		return account.validatePin(pin);
    	}
    	else {
    		return false;
    	}
    	
    }
    
    public double getAvailableBalance(int accountNumber) {
    	Account account = this.getAccount(accountNumber);
    	return account.getAvailableBalance();
    }
    
    public double getTotalBalance(int accountNumber) {
    	return this.getAccount(accountNumber).getTotalBalance();
    }
    
    public void credit(int accountNumber, double amount) {
    	this.getAccount(accountNumber).credit(amount);
    }
    
    public void debit(int accountNumber, double amount) {
    	this.getAccount(accountNumber).debit(amount);
    }

}
